import React, { Component } from 'react'
import Axios from 'axios'

export default class search extends Component {
    
    searchSong = (event) => {
        
        var that = this;
        const {target,keyCode} = event
        var resultList = [];
        if(keyCode === 13&&target.value!=null)
        {
            Axios.get("https://autumnfish.cn/search?keywords="+target.value).then(
                function(response){
                    console.log(response)
                    resultList = response.data.result;
                    that.props.testSearch(target.value,resultList);                      
                },function(err){
                    console.log(err)
                }
            )                  
        }
    }

    render() {
        return (
            <div className="header">
                <input type="text" className="search" onKeyUp={this.searchSong} placeholder="请输入歌手或歌曲名字~"/>
                &nbsp;
                <button type="button" onClick={this.searchSong}>搜索</button>  
            </div>
        )
    }
}
